const mongoose = require('mongoose');
const config = require('./environment');
const knex = require('knex')(config.crasheyeMySQL);
const bookshelf = require('bookshelf')(knex);

exports.crasheyeBookshelf = bookshelf;

exports.connectMonogoDB = () => {
  if (mongoose.db) {
    mongoose.db.disconnect();
  }

  mongoose.db = mongoose.connect(config.mongoDB.url, {server: {poolSize: config.mongoDB.poolSize}});
};
